void CHomeLibraryBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdLibraryFiles = m_pdLibraryVolume = m_pdLibraryHashRemaining = NULL; SetCaptionmark( _T("CHomeLibraryBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeLibraryBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Library") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_LIBRARYFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("LibraryFiles"), m_pdLibraryFiles ); pMap.Lookup( _T("LibraryVolume"), m_pdLibraryVolume ); pMap.Lookup( _T("LibraryHashRemaining"), m_pdLibraryHashRemaining ); SetDocument( m_pDocument ); Update(); // Update Dropshadow (Note: Caused app freeze when allowing hovered item during skin change) m_wndTip.DestroyWindow(); m_wndTip.Create( this, &Settings.Interface.TipLibrary ); }
Document::Document (const QString& filename, QObject *plugin) : DocURL_ (QUrl::fromLocalFile (filename)) , Plugin_ (plugin) { QFile file (filename); if (!file.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "unable to open file" << file.fileName () << file.errorString (); return; } QDomDocument doc; if (!doc.setContent (file.readAll (), true)) { qWarning () << Q_FUNC_INFO << "malformed XML in" << filename; return; } FB2Converter conv (this, doc); auto textDoc = conv.GetResult (); SetDocument (textDoc); Info_ = conv.GetDocumentInfo (); TOC_ = conv.GetTOC (); }
ezQtPropertyGridWidget::ezQtPropertyGridWidget(QWidget* pParent, ezDocument* pDocument, bool bBindToSelectionManager) : QWidget(pParent) { m_pDocument = nullptr; m_pScroll = new QScrollArea(this); m_pScroll->setContentsMargins(0, 0, 0, 0); m_pLayout = new QVBoxLayout(this); m_pLayout->setSpacing(0); m_pLayout->setMargin(0); setLayout(m_pLayout); m_pLayout->addWidget(m_pScroll); m_pContent = new QWidget(this); m_pScroll->setWidget(m_pContent); m_pScroll->setWidgetResizable(true); m_pContent->setBackgroundRole(QPalette::ColorRole::Window); m_pContent->setAutoFillBackground(true); m_pContentLayout = new QVBoxLayout(m_pContent); m_pContentLayout->setSpacing(1); m_pContentLayout->setMargin(1); m_pContent->setLayout(m_pContentLayout); m_pSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); m_pContentLayout->addSpacerItem(m_pSpacer); m_pTypeWidget = nullptr; s_Factory.m_Events.AddEventHandler(ezMakeDelegate(&ezQtPropertyGridWidget::FactoryEventHandler, this)); ezPhantomRttiManager::s_Events.AddEventHandler(ezMakeDelegate(&ezQtPropertyGridWidget::TypeEventHandler, this)); SetDocument(pDocument, bBindToSelectionManager); }
nsresult nsXPathEvaluator::Init() { nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(fOuter); return document ? SetDocument(document) : NS_OK; }
void CHomeConnectionBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdConnectedHours = m_pdConnectedMinutes = NULL; for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP ) { for ( int nT = ntNode ; nT <= ntLeaf ; nT++ ) { m_pdCount[ nP ][ nT ] = NULL; m_sCount[ nP ][ nT ].Empty(); } } SetCaptionmark( _T("CHomeConnectionBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeConnectionBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Connection") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_NEIGHBOURSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("ConnectedHours"), m_pdConnectedHours ); pMap.Lookup( _T("ConnectedMinutes"), m_pdConnectedMinutes ); pMap.Lookup( _T("G1Peers"), m_pdCount[PROTOCOL_G1][ntNode] ); pMap.Lookup( _T("G1Hubs"), m_pdCount[PROTOCOL_G1][ntHub] ); pMap.Lookup( _T("G1Leaves"), m_pdCount[PROTOCOL_G1][ntLeaf] ); pMap.Lookup( _T("G2Peers"), m_pdCount[PROTOCOL_G2][ntNode] ); pMap.Lookup( _T("G2Hubs"), m_pdCount[PROTOCOL_G2][ntHub] ); pMap.Lookup( _T("G2Leaves"), m_pdCount[PROTOCOL_G2][ntLeaf] ); pMap.Lookup( _T("EDServers"), m_pdCount[PROTOCOL_ED2K][ntHub] ); pMap.Lookup( _T("DCHubs"), m_pdCount[PROTOCOL_DC][ntHub] ); for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP ) { for ( int nT = ntNode ; nT < ntLast ; nT++ ) { if ( m_pdCount[ nP ][ nT ] != NULL ) m_sCount[ nP ][ nT ] = m_pdCount[ nP ][ nT ]->m_sText; } } SetDocument( m_pDocument ); Update(); }
void WaveformView::onAutoZoom() { if (fDoc) { fSampleWidth = DEFAULT_SAMPLE_WIDTH; fSamplesPerFrame = DEFAULT_SAMPLES_PER_FRAME; fSamplesPerSec = fDoc->Fps() * fSamplesPerFrame; fFrameWidth = fSampleWidth * fSamplesPerFrame; SetDocument(fDoc); } }
emPsDocumentPanel::emPsDocumentPanel( ParentArg parent, const emString & name, const emPsDocument & document ) : emPanel(parent,name) { BGColor=emColor(0,0,0,0); FGColor=emColor(0,0,0); PagePanels=NULL; CalcLayout(); SetDocument(document); }
void WaveformView::onZoomIn() { if (fDoc && fSamplesPerFrame < 16) { if (fSampleWidth < 2) { fSampleWidth = 2; fSamplesPerFrame = 1; fSamplesPerSec = fDoc->Fps() * fSamplesPerFrame; fFrameWidth = fSampleWidth * fSamplesPerFrame; SetDocument(fDoc); } else { fSamplesPerFrame *= 2; fSamplesPerSec = fDoc->Fps() * fSamplesPerFrame; fFrameWidth = fSampleWidth * fSamplesPerFrame; SetDocument(fDoc); } } }
ImageDetailsView::ImageDetailsView(ImageDetailsDocument *doc) : wxView() { SetDocument(doc); m_frame = wxGetApp().CreateChildFrame(this, false); m_frame->SetTitle("Image Details"); wxPanel * const panel = new wxPanel(m_frame); wxFlexGridSizer * const sizer = new wxFlexGridSizer(2, wxSize(5, 5)); const wxSizerFlags flags = wxSizerFlags().Align(wxALIGN_CENTRE_VERTICAL).Border(); sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &file:"), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, doc->GetFilename()), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &type:"), flags); wxString typeStr; switch ( doc->GetType() ) { case wxBITMAP_TYPE_PNG: typeStr = "PNG"; break; case wxBITMAP_TYPE_JPEG: typeStr = "JPEG"; break; default: typeStr = "Unknown"; } sizer->Add(new wxStaticText(panel, wxID_ANY, typeStr), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, "Image &size:"), flags); wxSize size = doc->GetSize(); sizer->Add(new wxStaticText(panel, wxID_ANY, wxString::Format("%d*%d", size.x, size.y)), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, "Number of unique &colours:"), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, wxString::Format("%lu", doc->GetNumColours())), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, "Uses &alpha:"), flags); sizer->Add(new wxStaticText(panel, wxID_ANY, doc->HasAlpha() ? "Yes" : "No"), flags); panel->SetSizer(sizer); m_frame->SetClientSize(panel->GetBestSize()); m_frame->Show(true); }
void WaveformView::onZoomOut() { if (fDoc) { if (fSamplesPerFrame > 1) { fSamplesPerFrame /= 2; if (fSamplesPerFrame < 1) fSamplesPerFrame = 1; fSamplesPerSec = fDoc->Fps() * fSamplesPerFrame; fFrameWidth = fSampleWidth * fSamplesPerFrame; SetDocument(fDoc); } else if (fSampleWidth > 2) { fSampleWidth /= 2; if (fSampleWidth < 1) fSampleWidth = 1; fSamplesPerSec = fDoc->Fps() * fSamplesPerFrame; fFrameWidth = fSampleWidth * fSamplesPerFrame; SetDocument(fDoc); } } }
Document::Document (const QString& filename, QObject *plugin) : DocURL_ (QUrl::fromLocalFile (filename)) , Plugin_ (plugin) { SetSettings (); QFile file (filename); if (!file.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "unable to open file" << file.fileName () << file.errorString (); return; } QDomDocument doc; if (!doc.setContent (file.readAll (), true)) { qWarning () << Q_FUNC_INFO << "malformed XML in" << filename; return; } FB2Converter conv (this, doc); auto textDoc = conv.GetResult (); const auto& defaultFont = XmlSettingsManager::Instance () .property ("DefaultFont").value<QFont> (); textDoc->setDefaultFont (defaultFont); textDoc->setPageSize (QSize { XmlSettingsManager::Instance ().property ("PageWidth").toInt (), XmlSettingsManager::Instance ().property ("PageHeight").toInt () }); SetDocument (textDoc); Info_ = conv.GetDocumentInfo (); TOC_ = conv.GetTOC (); }
void CHomeUploadsBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdUploadsNone = m_pdUploadsOne = m_pdUploadsMany = NULL; m_pdUploadedNone = m_pdUploadedOne = m_pdUploadedMany = NULL; m_pdTorrentsOne = m_pdTorrentsMany = NULL; SetCaptionmark( _T("CHomeUploadsBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeUploadsBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Uploads") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_UPLOADSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("UploadsNone"), m_pdUploadsNone ); pMap.Lookup( _T("UploadsOne"), m_pdUploadsOne ); pMap.Lookup( _T("UploadsMany"), m_pdUploadsMany ); pMap.Lookup( _T("UploadedNone"), m_pdUploadedNone ); pMap.Lookup( _T("UploadedOne"), m_pdUploadedOne ); pMap.Lookup( _T("UploadedMany"), m_pdUploadedMany ); pMap.Lookup( _T("TorrentsOne"), m_pdTorrentsOne ); pMap.Lookup( _T("TorrentsMany"), m_pdTorrentsMany ); if ( m_pdUploadedOne ) m_sUploadedOne = m_pdUploadedOne->m_sText; if ( m_pdUploadedMany ) m_sUploadedMany = m_pdUploadedMany->m_sText; if ( m_pdUploadsMany ) m_sUploadsMany = m_pdUploadsMany->m_sText; if ( m_pdTorrentsMany ) m_sTorrentsMany = m_pdTorrentsMany->m_sText; SetDocument( m_pDocument ); Update(); }
void CHomeDownloadsBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdDownloadsNone = m_pdDownloadsOne = m_pdDownloadsMany = NULL; m_pdDownloadedNone = m_pdDownloadedOne = m_pdDownloadedMany = m_pdDownloadedVolume = NULL; SetCaptionmark( _T("CHomeDownloadsBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeDownloadsBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Downloads") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_DOWNLOADSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("DownloadsNone"), m_pdDownloadsNone ); pMap.Lookup( _T("DownloadsOne"), m_pdDownloadsOne ); pMap.Lookup( _T("DownloadsMany"), m_pdDownloadsMany ); pMap.Lookup( _T("DownloadedNone"), m_pdDownloadedNone ); pMap.Lookup( _T("DownloadedOne"), m_pdDownloadedOne ); pMap.Lookup( _T("DownloadedMany"), m_pdDownloadedMany ); pMap.Lookup( _T("DownloadedVolume"), m_pdDownloadedVolume ); if ( m_pdDownloadsMany ) m_sDownloadsMany = m_pdDownloadsMany->m_sText; if ( m_pdDownloadedMany ) m_sDownloadedMany = m_pdDownloadedMany->m_sText; SetDocument( m_pDocument ); // Was GetView().SetDocument( m_pDocument ); Update(); // Update Dropshadow m_wndTip.DestroyWindow(); m_wndTip.Create( this, &Settings.Interface.TipDownloads ); }
const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) { p = SkipWhiteSpace(p, encoding); TiXmlDocument* document = GetDocument(); if (!p || !*p) { if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, nullptr, nullptr, encoding); return nullptr; } if (data) { data->Stamp(p, encoding); location = data->Cursor(); } if (*p != '<') { if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, p, data, encoding); return nullptr; } p = SkipWhiteSpace(p + 1, encoding); // Read the name. const char* pErr = p; p = ReadName(p, &value, encoding); if (!p || !*p) { if (document) document->SetError(TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding); return nullptr; } TIXML_STRING endTag("</"); endTag += value; endTag += ">"; // Check for and read attributes. Also look for an empty // tag or an end tag. while (p && *p) { pErr = p; p = SkipWhiteSpace(p, encoding); if (!p || !*p) { if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding); return nullptr; } if (*p == '/') { ++p; // Empty tag. if (*p != '>') { if (document) document->SetError(TIXML_ERROR_PARSING_EMPTY, p, data, encoding); return nullptr; } return (p + 1); } else if (*p == '>') { // Done with attributes (if there were any.) // Read the value -- which can include other // elements -- read the end tag, and return. ++p; p = ReadValue(p, data, encoding); // Note this is an Element method, and // will set the error if one happens. if (!p || !*p) { // We were looking for the end tag, but found nothing. // Fix for [ 1663758 ] Failure to report error on bad XML if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding); return nullptr; } // We should find the end tag now if (StringEqual(p, endTag.c_str(), false, encoding)) { p += endTag.length(); return p; } else { if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding); return nullptr; } } else { // Try to read an attribute: auto attrib = new TiXmlAttribute(); if (!attrib) { if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding); return nullptr; } attrib->SetDocument(document); pErr = p; p = attrib->Parse(p, data, encoding); if (!p || !*p) { if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding); delete attrib; return nullptr; } // Handle the strange case of double attributes: #ifdef TIXML_USE_STL TiXmlAttribute* node = attributeSet.Find(attrib->NameTStr()); #else TiXmlAttribute* node = attributeSet.Find(attrib->Name()); #endif if (node) { node->SetValue(attrib->Value()); delete attrib; return nullptr; } attributeSet.Add(attrib); } } return p; }
NS_IMETHODIMP nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, PRBool aEnableSelectionChecking) { nsresult rv; // We can spell check with any editor type nsCOMPtr<nsITextServicesDocument>tsDoc = do_CreateInstance("@mozilla.org/textservices/textservicesdocument;1", &rv); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(tsDoc, NS_ERROR_NULL_POINTER); tsDoc->SetFilter(mTxtSrvFilter); // Pass the editor to the text services document rv = tsDoc->InitWithEditor(aEditor); NS_ENSURE_SUCCESS(rv, rv); if (aEnableSelectionChecking) { // Find out if the section is collapsed or not. // If it isn't, we want to spellcheck just the selection. nsCOMPtr<nsISelection> selection; rv = aEditor->GetSelection(getter_AddRefs(selection)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); PRInt32 count = 0; rv = selection->GetRangeCount(&count); NS_ENSURE_SUCCESS(rv, rv); if (count > 0) { nsCOMPtr<nsIDOMRange> range; rv = selection->GetRangeAt(0, getter_AddRefs(range)); NS_ENSURE_SUCCESS(rv, rv); PRBool collapsed = PR_FALSE; rv = range->GetCollapsed(&collapsed); NS_ENSURE_SUCCESS(rv, rv); if (!collapsed) { // We don't want to touch the range in the selection, // so create a new copy of it. nsCOMPtr<nsIDOMRange> rangeBounds; rv = range->CloneRange(getter_AddRefs(rangeBounds)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(rangeBounds, NS_ERROR_FAILURE); // Make sure the new range spans complete words. rv = tsDoc->ExpandRangeToWordBoundaries(rangeBounds); NS_ENSURE_SUCCESS(rv, rv); // Now tell the text services that you only want // to iterate over the text in this range. rv = tsDoc->SetExtent(rangeBounds); NS_ENSURE_SUCCESS(rv, rv); } } } mSpellChecker = do_CreateInstance(NS_SPELLCHECKER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NULL_POINTER); rv = mSpellChecker->SetDocument(tsDoc, PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); // Tell the spellchecker what dictionary to use: nsXPIDLString dictName; nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && prefBranch) { nsCOMPtr<nsISupportsString> prefString; rv = prefBranch->GetComplexValue("spellchecker.dictionary", NS_GET_IID(nsISupportsString), getter_AddRefs(prefString)); if (NS_SUCCEEDED(rv) && prefString) prefString->GetData(dictName); } if (dictName.IsEmpty()) { // Prefs didn't give us a dictionary name, so just get the current // locale and use that as the default dictionary name! nsCOMPtr<nsIXULChromeRegistry> packageRegistry = mozilla::services::GetXULChromeRegistryService(); if (packageRegistry) { nsCAutoString utf8DictName; rv = packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), utf8DictName); AppendUTF8toUTF16(utf8DictName, dictName); } } PRBool setDictionary = PR_FALSE; if (NS_SUCCEEDED(rv) && !dictName.IsEmpty()) { rv = SetCurrentDictionary(dictName.get()); // fall back to "en-US" if the current locale doesn't have a dictionary. if (NS_FAILED(rv)) { rv = SetCurrentDictionary(NS_LITERAL_STRING("en-US").get()); } if (NS_SUCCEEDED(rv)) setDictionary = PR_TRUE; } // If there was no dictionary specified by spellchecker.dictionary and setting it to the // locale dictionary didn't work, try to use the first dictionary we find. This helps when // the first dictionary is installed if (! setDictionary) { nsTArray<nsString> dictList; rv = mSpellChecker->GetDictionaryList(&dictList); NS_ENSURE_SUCCESS(rv, rv); if (dictList.Length() > 0) { rv = SetCurrentDictionary(dictList[0].get()); if (NS_SUCCEEDED(rv)) SaveDefaultDictionary(); } } // If an error was thrown while checking the dictionary pref, just // fail silently so that the spellchecker dialog is allowed to come // up. The user can manually reset the language to their choice on // the dialog if it is wrong. DeleteSuggestedWordList(); return NS_OK; }
DocumentAdapter::DocumentAdapter (QTextDocument *doc) { SetDocument (doc); }
WordDOMDocumentTagger::WordDOMDocumentTagger(IDispatchPtr spDocument) { SetDocument(spDocument); }