本文整理汇总了C++中UT_DEBUGMSG函数的典型用法代码示例。如果您正苦于以下问题:C++ UT_DEBUGMSG函数的具体用法?C++ UT_DEBUGMSG怎么用?C++ UT_DEBUGMSG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UT_DEBUGMSG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getUserPrivateDirectory
bool AP_Win32App::initialize(void)
{
bool bSuccess = true;
const char * szUserPrivateDirectory = getUserPrivateDirectory();
bool bVerified = s_createDirectoryIfNecessary(szUserPrivateDirectory);
UT_return_val_if_fail (bVerified, false);
// create templates directory
UT_String sTemplates = szUserPrivateDirectory;
sTemplates += "/templates";
s_createDirectoryIfNecessary(sTemplates.c_str());
// load the preferences.
m_prefs = new AP_Win32Prefs();
UT_return_val_if_fail (m_prefs, false);
m_prefs->fullInit();
// now that preferences are established, let the xap init
m_pClipboard = new AP_Win32Clipboard();
UT_return_val_if_fail (m_pClipboard, false);
m_pEMC = AP_GetEditMethods();
UT_return_val_if_fail (m_pEMC, false);
m_pBindingSet = new AP_BindingSet(m_pEMC);
UT_return_val_if_fail (m_pBindingSet, false);
m_pMenuActionSet = AP_CreateMenuActionSet();
UT_return_val_if_fail (m_pMenuActionSet,false);
m_pToolbarActionSet = AP_CreateToolbarActionSet();
UT_return_val_if_fail (m_pToolbarActionSet,false);
//////////////////////////////////////////////////////////////////
// load the dialog and message box strings
//////////////////////////////////////////////////////////////////
{
// assume we will be using the builtin set (either as the main
// set or as the fallback set).
AP_BuiltinStringSet * pBuiltinStringSet = new AP_BuiltinStringSet(this,AP_PREF_DEFAULT_StringSet);
UT_return_val_if_fail (pBuiltinStringSet, false);
m_pStringSet = pBuiltinStringSet;
// see if we should load an alternate set from the disk
const char * szDirectory = NULL;
const char * szStringSet = NULL;
if ( (getPrefsValue(AP_PREF_KEY_StringSet,&szStringSet))
&& (szStringSet)
&& (*szStringSet)
&& (g_ascii_strcasecmp(szStringSet,AP_PREF_DEFAULT_StringSet) != 0))
{
getPrefsValueDirectory(true,AP_PREF_KEY_StringSetDirectory,&szDirectory);
UT_return_val_if_fail ((szDirectory) && (*szDirectory), false);
char * szPathname = (char *)UT_calloc(sizeof(char),strlen(szDirectory)+strlen(szStringSet)+100);
UT_return_val_if_fail (szPathname, false);
sprintf(szPathname,"%s%s%s.strings",
szDirectory,
((szDirectory[strlen(szDirectory)-1]=='\\') ? "" : "\\"),
szStringSet);
AP_DiskStringSet * pDiskStringSet = new AP_DiskStringSet(this);
UT_return_val_if_fail (pDiskStringSet, false);
if (pDiskStringSet->loadStringsFromDisk(szPathname))
{
pDiskStringSet->setFallbackStringSet(m_pStringSet);
m_pStringSet = pDiskStringSet;
UT_Language_updateLanguageNames();
UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname));
}
else
{
UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
DELETEP(pDiskStringSet);
}
g_free(szPathname);
}
}
// AP_App::initilize() calls for us XAP_Win32App::initialize()
if (! AP_App::initialize())
return false;
// let various window types register themselves
if (!AP_Win32Frame::RegisterClass(this))
{
UT_DEBUGMSG(("couldn't register class\n"));
//.........这里部分代码省略.........
示例2: OXML_Element_Table
//.........这里部分代码省略.........
if(val && !strcmp(val, "restart"))
{
cell->setHorizontalMergeStart(true);
}
rqst->handled = true;
}
//Table Properties
else if(nameMatches(rqst->pName, NS_W_KEY, "gridCol") &&
contextMatches(rqst->context->back(), NS_W_KEY, "tblGrid"))
{
if(m_tableStack.empty())
{
rqst->handled = false;
rqst->valid = false;
return;
}
OXML_Element_Table* table = m_tableStack.top();
const gchar* w = attrMatches(NS_W_KEY, "w", rqst->ppAtts);
if(w)
{
//append this width to table-column-props property
const gchar* tableColumnProps = NULL;
UT_Error ret = table->getProperty("table-column-props", tableColumnProps);
if((ret != UT_OK) || !tableColumnProps)
tableColumnProps = "";
std::string cols(tableColumnProps);
cols += _TwipsToPoints(w);
cols += "pt/";
ret = table->setProperty("table-column-props", cols);
if(ret != UT_OK)
{
UT_DEBUGMSG(("FRT:OpenXML importer can't set table-column-props:%s\n", cols.c_str()));
}
}
rqst->handled = true;
}
else if(nameMatches(rqst->pName, NS_W_KEY, "trHeight") &&
contextMatches(rqst->context->back(), NS_W_KEY, "trPr"))
{
if(m_tableStack.empty())
{
rqst->handled = false;
rqst->valid = false;
return;
}
OXML_Element_Table* table = m_tableStack.top();
const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
if(val)
{
const gchar* tableRowHeights = NULL;
UT_Error ret = table->getProperty("table-row-heights", tableRowHeights);
if((ret != UT_OK) || !tableRowHeights)
tableRowHeights = "";
std::string rowHeights(tableRowHeights);
rowHeights += _TwipsToPoints(val);
rowHeights += "pt/";
ret = table->setProperty("table-row-heights", rowHeights);
if(ret != UT_OK)
{
UT_DEBUGMSG(("FRT:OpenXML importer can't set table-row-heights:%s\n", rowHeights.c_str()));
}
}
rqst->handled = true;
示例3: g_thread_init
//.........这里部分代码省略.........
XAP_Args XArgs = XAP_Args(argc, argv);
AP_Args Args = AP_Args(&XArgs, szAppName, pMyUnixApp);
#ifdef LOGFILE
UT_String sLogFile = pMyUnixApp->getUserPrivateDirectory();
sLogFile += "abiLogFile";
logfile = fopen(sLogFile.c_str(),"a+");
fprintf(logfile,"About to do gtk_set_locale \n");
fprintf(logfile,"New logfile \n");
#endif
// Step 1: Initialize GTK and create the APP.
// hack needed to intialize gtk before ::initialize
setlocale(LC_ALL, "");
gboolean have_display = gtk_init_check(&argc, &argv);
#ifdef LOGFILE
fprintf(logfile,"Got display %d \n",have_display);
fprintf(logfile,"Really display %d \n",have_display);
#endif
if (have_display > 0) {
Args.addOptions(gtk_get_option_group(TRUE));
Args.parseOptions();
}
else {
// no display, but we still need to at least parse our own arguments, damnit, for --to, --to-png, and --print
Args.addOptions(gtk_get_option_group(FALSE));
Args.parseOptions();
}
// if the initialize fails, we don't have icons, fonts, etc.
if (!pMyUnixApp->initialize(have_display))
{
delete pMyUnixApp;
return -1; // make this something standard?
}
// Setup signal handlers, primarily for segfault
// If we segfaulted before here, we *really* blew it
struct sigaction sa;
sa.sa_handler = signalWrapper;
sigfillset(&sa.sa_mask); // We don't want to hear about other signals
sigdelset(&sa.sa_mask, SIGABRT); // But we will call abort(), so we can't ignore that
#if defined (SA_NODEFER) && defined (SA_RESETHAND)
sa.sa_flags = SA_NODEFER | SA_RESETHAND; // Don't handle nested signals
#else
sa.sa_flags = 0;
#endif
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
// TODO: handle SIGABRT
// Step 2: Handle all non-window args.
bool windowlessArgsWereSuccessful = true;
if (!Args.doWindowlessArgs(windowlessArgsWereSuccessful )) {
delete pMyUnixApp;
return (windowlessArgsWereSuccessful ? 0 : -1);
}
if (have_display) {
// Step 3: Create windows as appropriate.
// if some args are botched, it returns false and we should
// continue out the door.
// We used to check for bShowApp here. It shouldn't be needed
// anymore, because doWindowlessArgs was supposed to bail already. -PL
if (pMyUnixApp->openCmdLineFiles(&Args))
{
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
s_bInitDone = true;
pMyUnixApp->processStartupQueue();
#endif
// turn over control to gtk
gtk_main();
}
else
{
UT_DEBUGMSG(("DOM: not parsing command line or showing app\n"));
}
}
else {
fprintf(stderr, "No DISPLAY: this may not be what you want.\n");
exit_status = 1;
}
// unload all loaded plugins (remove some of the memory leaks shown at shutdown :-)
XAP_ModuleManager::instance().unloadAllPlugins();
// Step 4: Destroy the App. It should take care of deleting all frames.
pMyUnixApp->shutdown();
}
delete pMyUnixApp;
return exit_status;
}
示例4: UT_DEBUGMSG
TCPAccountHandler::~TCPAccountHandler()
{
UT_DEBUGMSG(("~TCPAccountHandler()\n"));
if (m_bConnected)
disconnect();
}
示例5: UT_DEBUGMSG
UT_Error IE_ImpGraphic_WMF::convertGraphic(UT_ByteBuf* pBBwmf,
UT_ByteBuf** ppBBpng)
{
UT_ByteBuf * pBBpng = 0;
wmf_error_t err;
wmf_gd_t * ddata = 0;
wmfAPI * API = 0;
wmfAPI_Options api_options;
wmfD_Rect bbox;
unsigned long flags;
#if 0 // the code that uses these two variables is in an if 0 block below
unsigned int max_width = 500;
unsigned int max_height = 500;
#endif
unsigned int width, height;
bbuf_read_info read_info;
bbuf_write_info write_info;
if (!pBBwmf) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Bad Arg (1)\n"));
return UT_ERROR;
}
if (!ppBBpng) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Bad Arg (2)\n"));
return UT_ERROR;
}
*ppBBpng = 0;
flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
api_options.function = wmf_gd_function;
err = wmf_api_create(&API,flags,&api_options);
if (err != wmf_E_None) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic No API\n"));
return UT_ERROR;
}
ddata = WMF_GD_GetData(API);
if ((ddata->flags & WMF_GD_SUPPORTS_PNG) == 0) { // Impossible, but...
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic No PNG\n"));
wmf_api_destroy(API);
return UT_ERROR;
}
read_info.pByteBuf = pBBwmf;
read_info.len = pBBwmf->getLength();
read_info.pos = 0;
err = wmf_bbuf_input (API,AbiWord_WMF_read,AbiWord_WMF_seek,AbiWord_WMF_tell,(void *) &read_info);
if (err != wmf_E_None) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Bad input set\n"));
wmf_api_destroy(API);
return UT_ERROR;
}
err = wmf_scan (API,0,&bbox);
if (err != wmf_E_None) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Scan failed\n"));
wmf_api_destroy(API);
return UT_ERROR;
}
/* TODO: be smarter about getting the resolution from screen
*/
double resolution_x, resolution_y;
resolution_x = resolution_y = 72.0;
err = wmf_display_size (API, &width, &height, resolution_x, resolution_y);
if (err != wmf_E_None) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Get size failed\n"));
wmf_api_destroy(API);
return UT_ERROR;
}
ddata->width = (unsigned int) width;
ddata->height = (unsigned int) height;
if ((ddata->width == 0) || (ddata->height == 0)) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Size error (1)\n"));
wmf_api_destroy(API);
return UT_ERROR;
}
#if 0
// not sure if this branch is needed any more after the recent changes
// done by FJF and myself inside of libWMF for better size detection - DAL
if ((ddata->width >= max_width) || (ddata->height >= max_height)) {
float ratio_wmf = height / width;
//.........这里部分代码省略.........
示例6: UT_DEBUGMSG
UT_Error IE_Exp_WordPerfect::_writeHeader()
{
int i = 0;
UT_DEBUGMSG(("WordPerfect Exporter::_writeHeader\n"));
m_buffer = new UT_String();
*m_buffer += (char)0xFF; // -1
*m_buffer += "WPC"; // WPC
_UT_String_add(*m_buffer, (int)0x00000000); // pointer to document area; THIS IS A DUMMY VALUE!
*m_buffer += (char)0x01; // program that created the file, WordPerfect itself = 1, we choose also 1 :-)
*m_buffer += (char)0x0A; // file type, WordPerfect document had type 0x0A
*m_buffer += (char)0x02; // major version of file, WP 8.0 = 2
*m_buffer += (char)0x01; // minor version of file, WP 8.0 = 1
_UT_String_add(*m_buffer, (short)0x0000); // encryption key; 0 means no encryption is used
_UT_String_add(*m_buffer, (short)0x0200); // offset to the index header = 0x200
*m_buffer += char(0x05); // reserved; beginning of extended file header, fixed entry count = 5
*m_buffer += (char)0x00; // reserved; completeness indicator
_UT_String_add(*m_buffer, (short)0x0000); // reserved; offset to proprietary data
_UT_String_add(*m_buffer, (int)0x00000000); // file size, not including pad charachters at EOF; THIS IS A DUMMY VALUE!
for (i=0; i<488; i++) { *m_buffer += (char)0x00; } // extended header, 488 bytes
// Index and Packet Data Areas follow
*m_buffer += (char)0x02; // index header; flags = 2
*m_buffer += (char)0x00; // index header; reserved = 0
_UT_String_add(*m_buffer, (short)0x0005); // index header; number of indexes in index block, we write 5 packets
for (i=0; i<10; i++) { *m_buffer += (char)0x00; } // index header; reserved = 0 x 10
// FIXME: clean me up
m_ptrDesiredFontUseCount = m_buffer->length() + 2;
// This is a piece of the index header which I can't figure out yet
// When I do figure out what it all means, I'll replace it with some nice header-writing functions
char magic[192] =
{
// Desired Font
(char)0x00, (char)0x55,
(char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x4E, (char)0x00, (char)0x00, (char)0x00, (char)0x46, (char)0x02, (char)0x00, (char)0x00,
// Initial Font
(char)0x09, (char)0x25, (char)0x01, (char)0x00,
(char)0x00, (char)0x00, (char)0x06, (char)0x00, (char)0x00, (char)0x00, (char)0x94, (char)0x02, (char)0x00, (char)0x00,
// Style Data
(char)0x0B, (char)0x30, (char)0x02, (char)0x00, (char)0x00, (char)0x00,
(char)0x28, (char)0x00, (char)0x00, (char)0x00, (char)0x9A, (char)0x02, (char)0x00, (char)0x00,
// Prefix Time Stamp
(char)0x08, (char)0x5E, (char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x0C, (char)0x00,
(char)0x00, (char)0x00, (char)0xC2, (char)0x02,
// Extra Desired Font Information
(char)0x00, (char)0x00,
(char)0x28, (char)0x00, (char)0xD6, (char)0x1E, (char)0xC3, (char)0x0f, (char)0x39, (char)0x08, (char)0x00, (char)0x00,
(char)0x11, (char)0x09, (char)0x00, (char)0x00, (char)0x00, (char)0x5A, (char)0x00, (char)0x1B, (char)0x01, (char)0x00, (char)0x8B, (char)0x14, (char)0x36, (char)0x00, (char)0x54, (char)0x00,
(char)0x69, (char)0x00, (char)0x6D, (char)0x00, (char)0x65, (char)0x00, (char)0x73, (char)0x00, (char)0x20, (char)0x00, (char)0x4E, (char)0x00, (char)0x65, (char)0x00, (char)0x77, (char)0x00,
(char)0x20, (char)0x00, (char)0x52, (char)0x00, (char)0x6F, (char)0x00, (char)0x6D, (char)0x00, (char)0x61, (char)0x00, (char)0x6E, (char)0x00, (char)0x20, (char)0x00, (char)0x52, (char)0x00,
(char)0x65, (char)0x00, (char)0x67, (char)0x00, (char)0x75, (char)0x00, (char)0x6C, (char)0x00, (char)0x61, (char)0x00, (char)0x72, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00,
(char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x00, (char)0x01, (char)0x00, (char)0x58, (char)0x02, (char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x04, (char)0x00,
(char)0x28, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00,
(char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x12, (char)0x02, (char)0x00, (char)0x24, (char)0x00, (char)0xA1, (char)0x00, (char)0x00, (char)0x00, (char)0xA1, (char)0x00,
(char)0x00, (char)0x00, (char)0x50, (char)0xA5, (char)0x4E, (char)0x25, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x08, (char)0x00,
};
// add the magic index contents to get a nice and working header
_UT_String_add_chars(*m_buffer, magic, 192);
// we're done writing the header, save this position as the start of document
m_ptrToDocument = m_buffer->length();
// write some global document properties now
_handleGlobalOn();
_handleGlobalOff();
return UT_OK;
}
示例7: UT_return_val_if_fail
/*!
* Sets given attribute in this PP_AttrProp bundle.
* Deals correctly with setting the PT_PROPS_ATTRIBUTE_NAME property:
* intercepts this call and appends properties instead.
*
* Because all mutations of attributes go through here, it is always the
* case that the props attribute is correctly handled.
*/
bool PP_AttrProp::setAttribute(const gchar * szName, const gchar * szValue)
{
// TODO when this assert fails, switch this file to use UT_XML_ version of str*() functions.
UT_return_val_if_fail (sizeof(char)==sizeof(gchar), false);
if (0 == strcmp(szName, PT_PROPS_ATTRIBUTE_NAME) && *szValue) // PROPS -- cut value up into properties
{
char * pOrig = NULL;
if (!(pOrig = g_strdup(szValue)))
{
UT_DEBUGMSG(("setAttribute: g_strdup() failed on [%s]\n",szValue));
return false;
}
// This function parses out CSS properties, separated by semicolons.
char *z = pOrig;
int bDone = 0;
while (!bDone)
{
// p will point to the property name. q will be the property value.
char *p = z;
char *q = p;
// skip the whitespace before the property name
while (isspace(*p))
p++;
// skip to the colon to find the value
while (*q && (*q != ':'))
q++;
// if there was no colon, this is invalid
if (!*q)
{
g_free(pOrig);
UT_DEBUGMSG(("props: %s\n", szValue));
return false;
}
// zero-out the colon, thus separating into two strings.
*q = 0;
q++;
// now, search ahead for the next semicolon, and separate this property from the next
z = q;
while (*z && (*z != ';'))
z++;
if (*z == ';')
{
*z = 0;
z++;
}
else
{
bDone = 1;
}
// skip the whitespace before the property value
while ((*q > 0) && isspace(*q))
q++;
setProperty(p, q);
}
g_free(pOrig);
return true;
}
else if (0 == strcmp(szName, PT_XID_ATTRIBUTE_NAME) && *szValue)
{
// XID is a unique id for the xml element / PT frag. Its function is to facilitate
// comparing/merging documents and we do not want it in the AP
return true;
}
else // not "PROPS" -- add to attribute list
{
UT_UTF8String url;
if (szValue && *szValue && (0 == strcmp(szName, "xlink:href") || 0 == strcmp(szName, "href")))
{
url = szValue;
url.decodeURL();
szValue = url.utf8_str();
}
if (!m_pAttributes)
{
m_pAttributes = new UT_GenericStringMap<gchar*>(5);
if (!m_pAttributes)
{
UT_DEBUGMSG(("setAttribute: could not allocate hash table.\n"));
return false;
//.........这里部分代码省略.........
示例8: UT_ASSERT
UT_Error UT_XML::parse (const char * szFilename)
{
UT_ASSERT (m_pListener || m_pExpertListener);
UT_ASSERT (szFilename);
if ((szFilename == 0) || ((m_pListener == 0) && (m_pExpertListener == 0))) return UT_ERROR;
if (!reset_all ()) return UT_OUTOFMEM;
UT_Error ret = UT_OK;
DefaultReader defaultReader;
Reader * reader = &defaultReader;
if (m_pReader)
reader = m_pReader;
if (!reader->openFile (szFilename))
{
UT_DEBUGMSG (("Could not open file %s\n", szFilename));
return UT_errnoToUTError ();
}
char buffer[2048];
m_bStopped = false;
xmlSAXHandler hdl;
xmlParserCtxtPtr ctxt = 0;
memset(&hdl, 0, sizeof(hdl));
hdl.getEntity = _getEntity;
hdl.startElement = _startElement;
hdl.endElement = _endElement;
hdl.characters = _charData;
hdl.error = _errorSAXFunc;
hdl.fatalError = _fatalErrorSAXFunc;
hdl.processingInstruction = _processingInstruction;
hdl.comment = _comment;
hdl.cdataBlock = _cdata;
size_t length = reader->readBytes (buffer, sizeof (buffer));
int done = (length < sizeof (buffer));
if (length != 0)
{
ctxt = xmlCreatePushParserCtxt (&hdl, static_cast<void *>(this), buffer, static_cast<int>(length), szFilename);
if (ctxt == NULL)
{
UT_DEBUGMSG (("Unable to create libxml2 push-parser context!\n"));
reader->closeFile ();
return UT_ERROR;
}
xmlSubstituteEntitiesDefault (1);
UT_sint32 chucks = -1;
while (!done && !m_bStopped)
{
chucks++;
length = reader->readBytes (buffer, sizeof (buffer));
UT_DEBUGMSG(("Done chunk %d length %zd \n",chucks,length));
done = (length < sizeof (buffer));
if (xmlParseChunk (ctxt, buffer, static_cast<int>(length), 0))
{
if(getNumMinorErrors() > getNumRecoveredErrors())
{
UT_DEBUGMSG (("Error - 1 parsing '%s' (Line: %d, Column: %d)\n", szFilename, xmlSAX2GetLineNumber(ctxt), xmlSAX2GetColumnNumber(ctxt)));
ret = UT_IE_IMPORTERROR;
break;
}
}
}
if (ret == UT_OK)
if (!m_bStopped && (getNumMinorErrors() == 0))
{
if (xmlParseChunk (ctxt, "", 0, 1))
{
UT_DEBUGMSG (("Error -2 parsing '%s' (Line: %d, Column: %d)\n", szFilename, xmlSAX2GetLineNumber(ctxt), xmlSAX2GetColumnNumber(ctxt)));
ret = UT_IE_IMPORTERROR;
}
}
if (ret == UT_OK && (getNumMinorErrors() == 0))
if (!ctxt->wellFormed && !m_bStopped) ret = UT_IE_IMPORTERROR; // How does stopping mid-file affect wellFormed?
xmlDocPtr myXmlDoc = ctxt->myDoc;
xmlFreeParserCtxt (ctxt);
xmlFreeDoc(myXmlDoc);
}
else
{
UT_DEBUGMSG(("Empty file to parse - not sure how to proceed\n"));
}
reader->closeFile ();
return ret;
}
示例9: getStyleTree
/*!
* Fill the GUI tree with the styles as defined in the XP tree.
*/
void AP_UnixDialog_Stylist::_fillTree(void)
{
Stylist_tree * pStyleTree = getStyleTree();
if(pStyleTree == NULL)
{
updateDialog();
pStyleTree = getStyleTree();
}
if(pStyleTree->getNumRows() == 0)
{
updateDialog();
pStyleTree = getStyleTree();
}
UT_DEBUGMSG(("Number of rows of styles in document %d \n",pStyleTree->getNumRows()));
if(m_wRenderer)
{
// g_object_unref (G_OBJECT (m_wRenderer));
gtk_widget_destroy (m_wStyleList);
}
GtkTreeIter iter;
GtkTreeIter child_iter;
GtkTreeSelection *sel;
UT_sint32 row,col, page;
m_wModel = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
page = 0;
UT_UTF8String sTmp("");
for(row= 0; row < pStyleTree->getNumRows();row++)
{
gtk_tree_store_append (m_wModel, &iter, NULL);
if(!pStyleTree->getNameOfRow(sTmp,row))
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
break;
}
if(pStyleTree->getNumCols(row) > 0)
{
xxx_UT_DEBUGMSG(("Adding Heading %s at row %d \n",sTmp.utf8_str(),row));
gtk_tree_store_set (m_wModel, &iter, 0, sTmp.utf8_str(), 1, row,2,0, -1);
for(col =0 ; col < pStyleTree->getNumCols(row); col++)
{
gtk_tree_store_append (m_wModel, &child_iter, &iter);
if(!pStyleTree->getStyleAtRowCol(sTmp,row,col))
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
break;
}
gtk_tree_store_set (m_wModel, &child_iter, 0, sTmp.utf8_str(), 1, row,2,col+1, -1);
xxx_UT_DEBUGMSG(("Adding style %s at row %d col %d \n",sTmp.utf8_str(),row,col+1));
page++;
}
}
else
{
xxx_UT_DEBUGMSG(("Adding style %s at row %d \n",sTmp.utf8_str(),row));
gtk_tree_store_set (m_wModel, &iter, 0, sTmp.utf8_str(), 1,row,2,0,-1);
page++;
}
}
// create a new treeview
m_wStyleList = gtk_tree_view_new_with_model (GTK_TREE_MODEL (m_wModel));
g_object_unref (G_OBJECT (m_wModel));
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (m_wStyleList), true);
// get the current selection
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_wStyleList));
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
gtk_tree_selection_set_select_function (sel, tree_select_filter,
NULL, NULL);
const XAP_StringSet * pSS = m_pApp->getStringSet ();
m_wRenderer = gtk_cell_renderer_text_new ();
UT_UTF8String s;
pSS->getValueUTF8(AP_STRING_ID_DLG_Stylist_Styles,s);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (m_wStyleList),
-1, s.utf8_str(),
m_wRenderer, "text", 0, NULL);
gtk_tree_view_collapse_all (GTK_TREE_VIEW (m_wStyleList));
gtk_container_add (GTK_CONTAINER (m_wStyleListContainer), m_wStyleList);
g_signal_connect_after(G_OBJECT(m_wStyleList),
"cursor-changed",
G_CALLBACK(s_types_clicked),
static_cast<gpointer>(this));
g_signal_connect_after(G_OBJECT(m_wStyleList),
"row-activated",
G_CALLBACK(s_types_dblclicked),
static_cast<gpointer>(this));
gtk_widget_show_all(m_wStyleList);
setStyleTreeChanged(false);
}
示例10: b1
void AP_UnixDialog_Lists::loadXPDataIntoLocal(void)
{
//
// This function reads the various memeber variables and loads them into
// into the dialog variables.
//
//
// Block all signals while setting these things
//
XAP_GtkSignalBlocker b1( G_OBJECT(m_oAlignList_adj), m_iAlignListSpinID);
XAP_GtkSignalBlocker b2( G_OBJECT(m_oIndentAlign_adj), m_iIndentAlignSpinID);
XAP_GtkSignalBlocker b3( G_OBJECT(m_wDecimalEntry), m_iDecimalEntryID);
XAP_GtkSignalBlocker b4( G_OBJECT(m_wDelimEntry), m_iDelimEntryID );
//
// HACK to effectively block an update during this method
//
m_bDontUpdate = true;
UT_DEBUGMSG(("loadXP newListType = %d \n",getNewListType()));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wAlignListSpin),getfAlign());
float indent = getfAlign() + getfIndent();
gtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin),indent);
if( (getfIndent() + getfAlign()) < 0.0)
{
setfIndent( - getfAlign());
gtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin), 0.0);
}
//
// Code to work out which is active Font
//
if(getFont() == "NULL")
{
gtk_combo_box_set_active(m_wFontOptions, 0 );
}
else
{
size_t i = 0;
for(std::vector<std::string>::const_iterator iter = m_glFonts.begin();
iter != m_glFonts.end(); ++iter, ++i)
{
if(*iter == getFont())
break;
}
if(i < m_glFonts.size())
{
gtk_combo_box_set_active(m_wFontOptions, i + 1 );
}
else
{
gtk_combo_box_set_active(m_wFontOptions, 0 );
}
}
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wStartSpin),static_cast<float>(getiStartValue()));
gtk_entry_set_text( GTK_ENTRY(m_wDecimalEntry), getDecimal().c_str());
gtk_entry_set_text( GTK_ENTRY(m_wDelimEntry), getDelim().c_str());
//
// Now set the list type and style
FL_ListType save = getNewListType();
if(getNewListType() == NOT_A_LIST)
{
styleChanged(0);
setNewListType(save);
gtk_combo_box_set_active(m_wListTypeBox, 0);
gtk_combo_box_set_active(m_wListStyleBox, 0);
}
else if(IS_BULLETED_LIST_TYPE(getNewListType()) )
{
styleChanged(1);
setNewListType(save);
gtk_combo_box_set_active(m_wListTypeBox, 1);
gtk_combo_box_set_active(m_wListStyleBox, (gint) (getNewListType() - BULLETED_LIST));
}
else
{
styleChanged(2);
setNewListType(save);
gtk_combo_box_set_active(m_wListTypeBox, 2);
if(getNewListType() < OTHER_NUMBERED_LISTS)
{
gtk_combo_box_set_active(m_wListStyleBox, getNewListType());
}
else
{
gint iMenu = static_cast<gint>(getNewListType()) - OTHER_NUMBERED_LISTS + BULLETED_LIST -1 ;
gtk_combo_box_set_active(m_wListStyleBox,iMenu);
}
}
//
// HACK to allow an update during this method
//
m_bDontUpdate = false;
}
示例11: GetDesktopWindow
bool AP_Win32App::_pasteFormatFromClipboard(PD_DocumentRange * pDocRange, const char * szFormat,
const char * szType, bool bWide)
{
HANDLE hData;
bool bSuccess = false;
if (!(hData = m_pClipboard->getHandleInFormat(szFormat)))
return bSuccess;
// It's a bitmap
if (g_ascii_strcasecmp(szFormat, AP_CLIPBOARD_BMP)==0)
{
HBITMAP hBitmap;
PBITMAPINFO bi;
HWND hWnd;
HDC hdc;
IE_ImpGraphic* pIEG = NULL;
FG_Graphic* pFG = NULL;
UT_Error errorCode;
UT_ByteBuf byteBuf;
IEGraphicFileType iegft = IEGFT_BMP;
XAP_Frame* pFrame;
AP_FrameData* pFrameData;
FL_DocLayout* pDocLy;
FV_View* pView;
UT_ByteBuf* bBufBMP = new UT_ByteBuf;
hBitmap = (HBITMAP)hData;
hWnd = GetDesktopWindow();
hdc = GetDC(hWnd);
// Create a BMP file from a BITMAP
bi = CreateBitmapInfoStruct(hBitmap);
CreateBMP(hWnd, *bBufBMP, bi, hBitmap,hdc);
// Since we are providing the file type, there is not need to pass the bytebuff filled up
errorCode = IE_ImpGraphic::constructImporter(*bBufBMP, iegft, &pIEG);
if(errorCode != UT_OK)
return false;
errorCode = pIEG->importGraphic(bBufBMP, &pFG);
if(errorCode != UT_OK || !pFG)
{
DELETEP(bBufBMP);
DELETEP(pIEG);
return false;
}
// sunk in importGraphic
bBufBMP = NULL;
// Insert graphic in the view
pFrame = getLastFocussedFrame();
pFrameData = (AP_FrameData*) pFrame->getFrameData();
pDocLy = pFrameData->m_pDocLayout;
pView = pDocLy->getView();
errorCode = pView->cmdInsertGraphic(pFG);
DELETEP(pIEG);
//DELETEP(pFG);
bSuccess = true;
}
else
{
unsigned char * pData = static_cast<unsigned char *>(GlobalLock(hData));
UT_DEBUGMSG(("Paste: [fmt %s %s][hdata 0x%08lx][pData 0x%08lx]\n",
szFormat, szType, hData, pData));
UT_uint32 iSize = GlobalSize(hData);
UT_uint32 iStrLen = bWide
? wcslen(reinterpret_cast<const wchar_t *>(pData)) * 2
: strlen(reinterpret_cast<const char *>(pData));
UT_uint32 iLen = UT_MIN(iSize,iStrLen);
IE_Imp * pImp = 0;
IE_Imp::constructImporter(pDocRange->m_pDoc, IE_Imp::fileTypeForSuffix(szType), &pImp, 0);
if (pImp)
{
const char * szEncoding = 0;
if (bWide)
szEncoding = XAP_EncodingManager::get_instance()->getUCS2LEName();
else
; // TODO Get code page using CF_LOCALE
pImp->pasteFromBuffer(pDocRange,pData,iLen,szEncoding);
delete pImp;
}
GlobalUnlock(hData);
bSuccess = true;
}
return bSuccess;
}
示例12: UT_return_val_if_fail
/*!
copy data in required format to the clipboard
*/
bool AP_Win32App::_copyFmtToClipboard(PD_DocumentRange * pDocRange, const char * pszFmt)
{
UT_return_val_if_fail(m_pClipboard && pszFmt, false);
UT_ByteBuf buf;
UT_Error status;;
UT_Byte b = 0;
if(0 == strcmp(AP_CLIPBOARD_TEXTPLAIN_8BIT, pszFmt))
{
IE_Exp_Text * pExpText = new IE_Exp_Text(pDocRange->m_pDoc);
if (pExpText)
{
status = pExpText->copyToBuffer(pDocRange,&buf);
if(status != UT_OK)
return false;
buf.append(&b,1); // NULL terminate the string
m_pClipboard->addData(AP_CLIPBOARD_TEXTPLAIN_8BIT,
(UT_Byte *)buf.getPointer(0),buf.getLength());
DELETEP(pExpText);
UT_DEBUGMSG(("CopyToClipboard: copying %d bytes in TEXTPLAIN format.\n",
buf.getLength()));
}
else
{
return false;
}
}
else if(0 == strcmp(AP_CLIPBOARD_TEXTPLAIN_UCS2, pszFmt))
{
const char *szEnc = XAP_EncodingManager::get_instance()->getNativeUnicodeEncodingName();
IE_Exp_Text * pExpUnicodeText = new IE_Exp_Text(pDocRange->m_pDoc,szEnc);
if (pExpUnicodeText)
{
status = pExpUnicodeText->copyToBuffer(pDocRange,&buf);
if(status != UT_OK)
return false;
UT_Byte b[2] = {0,0};
buf.append(b,2); // NULL terminate the string
m_pClipboard->addData(AP_CLIPBOARD_TEXTPLAIN_UCS2,
(UT_Byte *)buf.getPointer(0),buf.getLength());
DELETEP(pExpUnicodeText);
UT_DEBUGMSG(("CopyToClipboard: copying %d bytes in TEXTPLAIN UNICODE format.\n",
buf.getLength()*2));
}
else
{
return false;
}
}
else if(0 == strcmp(AP_CLIPBOARD_RTF, pszFmt))
{
IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
if (pExpRtf)
{
status = pExpRtf->copyToBuffer(pDocRange,&buf);
if(status != UT_OK)
return false;
buf.append(&b,1); // NULL terminate the string
m_pClipboard->addData(AP_CLIPBOARD_RTF,(UT_Byte *)buf.getPointer(0),buf.getLength());
DELETEP(pExpRtf);
UT_DEBUGMSG(("CopyFmtToClipboard: copying %d bytes in RTF format.\n",
buf.getLength()));
}
else
{
return false;
}
}
return true;
}
示例13: UT_DEBUGMSG
/*!
* Set all pagesize parameters via const gchar attributes
*/
bool fp_PageSize::Set(const gchar ** attributes)
{
const gchar * szPageSize=NULL, * szOrientation=NULL, * szWidth=NULL, * szHeight=NULL, * szUnits=NULL, * szPageScale=NULL;
double width=0.0;
double height=0.0;
double scale =1.0;
UT_Dimension u = DIM_IN;
for (const gchar ** a = attributes; (*a); a++)
{
UT_DEBUGMSG(("PageSize -prop %s value %s \n",a[0],a[1]));
if (strcmp(a[0],"pagetype") == 0)
szPageSize = a[1];
else if (strcmp(a[0], "orientation") == 0)
szOrientation = a[1];
else if (strcmp(a[0], "width") == 0)
szWidth = a[1];
else if (strcmp(a[0], "height") == 0)
szHeight = a[1];
else if (strcmp(a[0], "units") == 0)
szUnits = a[1];
else if (strcmp(a[0], "page-scale") == 0)
szPageScale = a[1];
a++;
}
if(!szPageSize)
return false;
if(!szOrientation)
return false;
Set(static_cast<const char *>(szPageSize));
if( szWidth && szHeight && szUnits && szPageScale)
{
if(g_ascii_strcasecmp(szPageSize,"Custom") == 0)
{
width = UT_convertDimensionless(szWidth);
height = UT_convertDimensionless(szHeight);
if(strcmp(szUnits,"cm") == 0)
u = DIM_CM;
else if(strcmp(szUnits,"mm") == 0)
u = DIM_MM;
else if(strcmp(szUnits,"inch") == 0)
u = DIM_IN;
Set(width,height,u);
}
scale = UT_convertDimensionless(szPageScale);
setScale(scale);
}
// set portrait by default
setPortrait();
if( g_ascii_strcasecmp(szOrientation,"landscape") == 0 )
{
// Note: setting landscape causes the width and height to be swapped
if (szWidth && szHeight && szUnits) // just setting a custom width or height should be allowed imo, but I'm lazy - MARCM
{
width = UT_convertDimensionless(szWidth);
height = UT_convertDimensionless(szHeight);
if(strcmp(szUnits,"cm") == 0)
u = DIM_CM;
else if(strcmp(szUnits,"mm") == 0)
u = DIM_MM;
else if(strcmp(szUnits,"inch") == 0)
u = DIM_IN;
setLandscape();
Set(height,width,u);
}
else
{
Set(m_iHeight, m_iWidth, FUND);
}
}
UT_DEBUGMSG(("PageSize - Height %lf Width %lf \n",m_iHeight,m_iWidth));
return true;
}
示例14: wmf_api_create
UT_Error IE_ImpGraphic_WMF::convertGraphicToSVG(UT_ByteBuf* pBBwmf, UT_ByteBuf** ppBB)
{
int status = 0;
unsigned int disp_width = 0;
unsigned int disp_height = 0;
float wmf_width;
float wmf_height;
float ratio_wmf;
float ratio_bounds;
unsigned long flags;
unsigned int max_width = 768;
unsigned int max_height = 512;
unsigned long max_flags = 0;
static const char* Default_Description = "wmf2svg";
wmf_error_t err;
wmf_svg_t* ddata = 0;
wmfAPI* API = 0;
wmfD_Rect bbox;
wmfAPI_Options api_options;
bbuf_read_info read_info;
char *stream = NULL;
unsigned long stream_len = 0;
*ppBB = 0;
flags = 0;
flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
api_options.function = wmf_svg_function;
err = wmf_api_create (&API,flags,&api_options);
status = explicit_wmf_error ("wmf_api_create",err);
if (status)
{
if (API)
wmf_api_destroy (API);
return (UT_ERROR);
}
read_info.pByteBuf = pBBwmf;
read_info.len = pBBwmf->getLength();
read_info.pos = 0;
err = wmf_bbuf_input (API,AbiWord_WMF_read,AbiWord_WMF_seek,AbiWord_WMF_tell,(void *) &read_info);
if (err != wmf_E_None) {
UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Bad input set\n"));
goto ErrorHandler;
}
err = wmf_scan (API,0,&(bbox));
status = explicit_wmf_error ("wmf_scan",err);
if (status)
{
goto ErrorHandler;
}
/* Okay, got this far, everything seems cool.
*/
ddata = WMF_SVG_GetData (API);
ddata->out = wmf_stream_create(API, NULL);
ddata->Description = (char *)Default_Description;
ddata->bbox = bbox;
wmf_display_size (API,&disp_width,&disp_height,72,72);
wmf_width = (float) disp_width;
wmf_height = (float) disp_height;
if ((wmf_width <= 0) || (wmf_height <= 0))
{ fputs ("Bad image size - but this error shouldn't occur...\n",stderr);
status = 1;
wmf_api_destroy (API);
return UT_ERROR;
}
if ((wmf_width > (float) max_width )
|| (wmf_height > (float) max_height))
{ if (max_flags == 0) max_flags = WMF2SVG_MAXPECT;
}
if (max_flags == WMF2SVG_MAXPECT) /* scale the image */
{ ratio_wmf = wmf_height / wmf_width;
ratio_bounds = (float) max_height / (float) max_width;
//.........这里部分代码省略.........
示例15: PD_Document
/*!
* This method copies the selection defined by pDocRange to ODT format
* placed in the ByteBuf bufODT
*/
UT_Error IE_Exp_OpenDocument::copyToBuffer(PD_DocumentRange * pDocRange,UT_ByteBuf * bufODT)
{
//
// First export selected range to a tempory document
//
PD_Document * outDoc = new PD_Document();
outDoc->createRawDocument();
IE_Exp_DocRangeListener * pRangeListener = new IE_Exp_DocRangeListener(pDocRange,outDoc);
UT_DEBUGMSG(("DocumentRange low %d High %d \n",pDocRange->m_pos1,pDocRange->m_pos2));
PL_ListenerCoupleCloser* pCloser = new PL_ListenerCoupleCloser();
pDocRange->m_pDoc->tellListenerSubset(pRangeListener,pDocRange,pCloser);
if( pCloser)
delete pCloser;
//
// Grab the RDF triples while we are copying...
//
if( PD_DocumentRDFHandle outrdf = outDoc->getDocumentRDF() )
{
std::set< std::string > xmlids;
PD_DocumentRDFHandle inrdf = pDocRange->m_pDoc->getDocumentRDF();
inrdf->addRelevantIDsForRange( xmlids, pDocRange );
if( !xmlids.empty() )
{
UT_DEBUGMSG(("MIQ: ODF export creating restricted RDF model xmlids.sz:%ld \n",(long)xmlids.size()));
PD_RDFModelHandle subm = inrdf->createRestrictedModelForXMLIDs( xmlids );
PD_DocumentRDFMutationHandle m = outrdf->createMutation();
m->add( subm );
m->commit();
subm->dumpModel("copied rdf triples subm");
outrdf->dumpModel("copied rdf triples result");
}
// PD_DocumentRDFMutationHandle m = outrdf->createMutation();
// m->add( PD_URI("http://www.example.com/foo"),
// PD_URI("http://www.example.com/bar"),
// PD_Literal("copyToBuffer path") );
// m->commit();
}
outDoc->finishRawCreation();
//
// OK now we have a complete and valid document containing our selected
// content. We export this to an in memory GSF buffer
//
IE_Exp * pNewExp = NULL;
char *szTempFileName = NULL;
GError *err = NULL;
g_file_open_tmp ("XXXXXX", &szTempFileName, &err);
GsfOutput * outBuf = gsf_output_stdio_new (szTempFileName,&err);
IEFileType ftODT = IE_Exp::fileTypeForMimetype("application/vnd.oasis.opendocument.text");
UT_Error aerr = IE_Exp::constructExporter(outDoc,outBuf,
ftODT,&pNewExp);
if(pNewExp == NULL)
{
return aerr;
}
aerr = pNewExp->writeFile(szTempFileName);
if(aerr != UT_OK)
{
delete pNewExp;
delete pRangeListener;
UNREFP( outDoc);
g_remove(szTempFileName);
g_free (szTempFileName);
return aerr;
}
//
// File is closed at the end of the export. Open it again.
//
GsfInput * fData = gsf_input_stdio_new(szTempFileName,&err);
UT_DebugOnly<UT_sint32> siz = gsf_input_size(fData);
const UT_Byte * pData = gsf_input_read(fData,gsf_input_size(fData),NULL);
UT_DEBUGMSG(("Writing %d bytes to clipboard \n", (UT_sint32)siz));
bufODT->append( pData, gsf_input_size(fData));
delete pNewExp;
delete pRangeListener;
UNREFP( outDoc);
g_remove(szTempFileName);
g_free (szTempFileName);
return aerr;
}