diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-03 09:59:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-03 20:24:00 +0100 |
commit | 3d826d780af366c7ed650ec44e7bcb20b02e2c70 (patch) | |
tree | 5b0d79f92a64eaa11667a20edaf6392e42480b02 /vcl/inc | |
parent | 12f9fdfac8b41d74e9474e8966e3d28755424931 (diff) |
make some headers private
as shown with ./bin/find-headers-to-move-inside-modules.py
Change-Id: I7662417e76fe00c0fc352957560e104b6c2a3d61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87850
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/IconThemeScanner.hxx | 92 | ||||
-rw-r--r-- | vcl/inc/IconThemeSelector.hxx | 97 | ||||
-rw-r--r-- | vcl/inc/OptionalBox.hxx | 42 | ||||
-rw-r--r-- | vcl/inc/configsettings.hxx | 66 | ||||
-rw-r--r-- | vcl/inc/debugevent.hxx | 36 | ||||
-rw-r--r-- | vcl/inc/imagerepository.hxx | 59 | ||||
-rw-r--r-- | vcl/inc/jobdata.hxx | 87 | ||||
-rw-r--r-- | vcl/inc/pch/precompiled_vcl.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/ppdparser.hxx | 274 | ||||
-rw-r--r-- | vcl/inc/printerinfomanager.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/strhelper.hxx | 72 | ||||
-rw-r--r-- | vcl/inc/unx/genprn.h | 2 | ||||
-rw-r--r-- | vcl/inc/unx/printerjob.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/vclstatuslistener.hxx | 108 |
14 files changed, 938 insertions, 4 deletions
diff --git a/vcl/inc/IconThemeScanner.hxx b/vcl/inc/IconThemeScanner.hxx new file mode 100644 index 000000000000..3cbca74a4683 --- /dev/null +++ b/vcl/inc/IconThemeScanner.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_ICONTHEMESCANNER_HXX +#define INCLUDED_VCL_ICONTHEMESCANNER_HXX + +#include <vcl/dllapi.h> + +#include <rtl/ustring.hxx> +#include <vcl/IconThemeInfo.hxx> + +#include <memory> +#include <vector> + +// forward declaration of unit test class. Required for friend relationship. +class IconThemeScannerTest; + +namespace vcl { + +/** This class scans a folder for icon themes and provides the results. + */ +class VCL_DLLPUBLIC IconThemeScanner +{ +public: + /** Factory method to create the object. + * Provide a path to search for IconThemes. + */ + static std::shared_ptr<IconThemeScanner> Create(const OUString &path); + + /** This method will return the standard path where icon themes are located. + */ + static OUString + GetStandardIconThemePath(); + + const std::vector<IconThemeInfo>& + GetFoundIconThemes() const {return mFoundIconThemes;} + + /** Get the IconThemeInfo for a theme. + * If the theme id is not among the found themes, a std::runtime_error will be thrown. + * Use IconThemeIsInstalled() to check whether it is available. + */ + const IconThemeInfo& GetIconThemeInfo(const OUString& themeId); + + /** Checks whether the theme with the provided name has been found in the + * scanned directory. + */ + bool + IconThemeIsInstalled(const OUString& themeId) const; + +private: + IconThemeScanner(); + + /** Scan a directory for icon themes. + * + * @return + * There are several cases when this method will fail: + * - The directory does not exist + * - There are no files which match the pattern images_xxx.zip + */ + void ScanDirectoryForIconThemes(const OUString &path); + + /** Adds the provided icon theme by path. + */ + bool + AddIconThemeByPath(const OUString &path); + + /** Scans the provided directory for icon themes. + * The returned strings will contain the URLs to the icon themes. + */ + static std::vector<OUString> + ReadIconThemesFromPath(const OUString& dir); + + /** Check whether a single file is valid */ + static bool + FileIsValidIconTheme(const OUString&); + + std::vector<IconThemeInfo> mFoundIconThemes; + + friend class ::IconThemeScannerTest; +}; + +} // end namespace vcl + +#endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/IconThemeSelector.hxx b/vcl/inc/IconThemeSelector.hxx new file mode 100644 index 000000000000..0fcd66d1f263 --- /dev/null +++ b/vcl/inc/IconThemeSelector.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_ICONTHEMESELECTOR_HXX +#define INCLUDED_VCL_ICONTHEMESELECTOR_HXX + +#include <rtl/ustring.hxx> + +#include <vcl/dllapi.h> + +#include <vector> + +// forward declaration of unit test class. Required for friend relationship. +class IconThemeSelectorTest; + +namespace vcl { +class IconThemeInfo; + +/** This class helps to choose an icon theme from a list of installed themes. + * + * The following factors influence the selection: + * -# When high contrast mode is enabled, the high contrast icon theme is selected (if it is installed). + * -# When a preferred theme has been set (e.g., in the gnome desktop settings), that theme is selected. + */ +class VCL_DLLPUBLIC IconThemeSelector { +public: + IconThemeSelector(); + + /** Select an icon theme from the list of installed themes. + * + * If high contrast mode has been enabled, the highcontrast theme will be selected (if it is available). + * + * @pre + * @p installedThemes must not be empty + */ + OUString + SelectIconTheme( + const std::vector<IconThemeInfo>& installedThemes, + const OUString& theme + ) const; + + /** Select the standard icon theme for a desktop environment from a list of installed themes. + * + * If a preferred theme has been set, this one will take precedence. + * + * The same logic as in SelectIconTheme() will apply. + * + * @pre + * @p installedThemes must not be empty + */ + OUString + SelectIconThemeForDesktopEnvironment( + const std::vector<IconThemeInfo>& installedThemes, + const OUString& desktopEnvironment) const; + + void + SetUseHighContrastTheme(bool); + + void + SetPreferredIconTheme(const OUString&, bool bDarkIconTheme); + + bool + operator==(const vcl::IconThemeSelector&) const; + + bool + operator!=(const vcl::IconThemeSelector&) const; + +private: + /** Return the first element of the themes, or the fallback if the vector is empty */ + static OUString + ReturnFallback(const std::vector<IconThemeInfo>& installedThemes); + + /** The name of the icon theme which is used as fallback */ + static const OUStringLiteral FALLBACK_ICON_THEME_ID; + + + static OUString + GetIconThemeForDesktopEnvironment(const OUString& desktopEnvironment); + + OUString mPreferredIconTheme; + bool mUseHighContrastTheme; + bool mPreferDarkIconTheme; + + friend class ::IconThemeSelectorTest; +}; + +} /* namespace vcl */ + +#endif // INCLUDED_VCL_ICONTHEMESELECTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/OptionalBox.hxx b/vcl/inc/OptionalBox.hxx new file mode 100644 index 000000000000..326fc7536c2d --- /dev/null +++ b/vcl/inc/OptionalBox.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_OPTIONALBOX_HXX +#define INCLUDED_VCL_OPTIONALBOX_HXX + +#include <vcl/IPrioritable.hxx> +#include <vcl/layout.hxx> + +class OptionalBox final : public VclHBox, public vcl::IPrioritable +{ +private: + bool m_bInFullView; + +public: + explicit OptionalBox(vcl::Window* pParent); + virtual ~OptionalBox() override; + + void HideContent() override; + void ShowContent() override; + bool IsHidden() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/configsettings.hxx b/vcl/inc/configsettings.hxx new file mode 100644 index 000000000000..967387499b9d --- /dev/null +++ b/vcl/inc/configsettings.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_VCL_CONFIGSETTINGS_HXX +#define INCLUDED_VCL_CONFIGSETTINGS_HXX + +#include <rtl/ustring.hxx> +#include <unotools/configitem.hxx> +#include <vcl/dllapi.h> + +#include <unordered_map> + +namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } } + +namespace vcl +{ + typedef std::unordered_map< OUString, OUString > OUStrMap; + class SmallOUStrMap : public OUStrMap { public: SmallOUStrMap() : OUStrMap(1) {} }; + + + //= SettingsConfigItem + + class VCL_DLLPUBLIC SettingsConfigItem final : public ::utl::ConfigItem + { + private: + std::unordered_map< OUString, SmallOUStrMap > m_aSettings; + + virtual void Notify( const css::uno::Sequence< OUString >& rPropertyNames ) override; + + void getValues(); + SettingsConfigItem(); + + virtual void ImplCommit() override; + + public: + virtual ~SettingsConfigItem() override; + + static SettingsConfigItem* get(); + + OUString getValue( const OUString& rGroup, const OUString& rKey ) const; + void setValue( const OUString& rGroup, const OUString& rKey, const OUString& rValue ); + + }; + + +} // namespace vcl + + +#endif // INCLUDED_VCL_CONFIGSETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/debugevent.hxx b/vcl/inc/debugevent.hxx new file mode 100644 index 000000000000..a6f458265cbb --- /dev/null +++ b/vcl/inc/debugevent.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_DEBUGEVENT_HXX +#define INCLUDED_VCL_DEBUGEVENT_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <sal/types.h> + +namespace vcl { class Window; } + +class DebugEventInjector final : private Timer { + sal_uInt32 mnEventsLeft; + DebugEventInjector( sal_uInt32 nMaxEvents ); + + static vcl::Window *ChooseWindow(); + static void InjectTextEvent(); + static void InjectMenuEvent(); + static void InjectEvent(); + static void InjectKeyNavEdit(); + virtual void Invoke() override; + + public: + static DebugEventInjector *getCreate(); +}; + +#endif // INCLUDED_VCL_DEBUGEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/imagerepository.hxx b/vcl/inc/imagerepository.hxx new file mode 100644 index 000000000000..a1a28d3fa241 --- /dev/null +++ b/vcl/inc/imagerepository.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_IMAGEREPOSITORY_HXX +#define INCLUDED_VCL_IMAGEREPOSITORY_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> + +class BitmapEx; + + +namespace vcl +{ + + + //= ImageRepository + + // provides access to the application's image repository (image.zip) + class ImageRepository + { + public: + /** loads an image from the application's image repository + @param _rName + the name of the image to load. + @param _out_rImage + will take the image upon successful return. + @return + whether or not the image could be loaded successfully. + */ + static bool loadImage( + const OUString& _rName, + BitmapEx& _out_rImage + ); + }; + + +} // namespace vcl + + +#endif // INCLUDED_VCL_IMAGEREPOSITORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/jobdata.hxx b/vcl/inc/jobdata.hxx new file mode 100644 index 000000000000..714bcb38137a --- /dev/null +++ b/vcl/inc/jobdata.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_JOBDATA_HXX +#define INCLUDED_VCL_JOBDATA_HXX + +#include "ppdparser.hxx" + +namespace psp { + +enum class orientation { + Portrait, + Landscape +}; + +struct VCL_DLLPUBLIC JobData +{ + int m_nCopies; + bool m_bCollate; + int m_nLeftMarginAdjust; + int m_nRightMarginAdjust; + int m_nTopMarginAdjust; + int m_nBottomMarginAdjust; + // user overrides for PPD + int m_nColorDepth; + int m_nPSLevel; // 0: no override, else languagelevel to use + int m_nColorDevice; // 0: no override, -1 grey scale, +1 color + int m_nPDFDevice; // 0: no override, -1 PostScript, +1: Automatically PDF, +2: Explicitly PDF + orientation m_eOrientation; + OUString m_aPrinterName; + bool m_bPapersizeFromSetup; + const PPDParser* m_pParser; + PPDContext m_aContext; + + JobData() : + m_nCopies( 1 ), + m_bCollate(false), + m_nLeftMarginAdjust( 0 ), + m_nRightMarginAdjust( 0 ), + m_nTopMarginAdjust( 0 ), + m_nBottomMarginAdjust( 0 ), + m_nColorDepth( 24 ), + m_nPSLevel( 0 ), + m_nColorDevice( 0 ), + m_nPDFDevice( 0 ), + m_eOrientation( orientation::Portrait ), + m_bPapersizeFromSetup( false ), + m_pParser( nullptr ) {} + + JobData& operator=(const psp::JobData& rRight); + + JobData( const JobData& rData ) { *this = rData; } + + void setCollate( bool bCollate ); + void setPaper( int nWidth, int nHeight ); // dimensions in pt + void setPaperBin( int nPaperBin ); + void resolveDefaultBackend(); + void setDefaultBackend(bool bUsePDF); + + // creates a new buffer using new + // it is up to the user to delete it again + bool getStreamBuffer( void*& pData, sal_uInt32& bytes ); + static bool constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, JobData& rJobData ); +}; + +} // namespace + + +#endif // PSPRINT_JOBDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index 01b514eb1d88..81dc449fbafb 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -271,7 +271,7 @@ #include <vcl/canvastools.hxx> #include <vcl/commandevent.hxx> #include <vcl/commandinfoprovider.hxx> -#include <vcl/configsettings.hxx> +#include <configsettings.hxx> #include <vcl/ctrl.hxx> #include <vcl/cursor.hxx> #include <vcl/cvtgrf.hxx> diff --git a/vcl/inc/ppdparser.hxx b/vcl/inc/ppdparser.hxx new file mode 100644 index 000000000000..a0a59c4a8d80 --- /dev/null +++ b/vcl/inc/ppdparser.hxx @@ -0,0 +1,274 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_VCL_PPDPARSER_HXX +#define INCLUDED_VCL_PPDPARSER_HXX + +#include <sal/config.h> + +#include <cstddef> +#include <memory> +#include <unordered_map> +#include <vector> + +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> + +#define PRINTER_PPDDIR "driver" + +namespace psp { + +class PPDCache; +class PPDTranslator; + +enum PPDValueType { eInvocation, eQuoted, eSymbol, eString, eNo }; + +struct VCL_DLLPUBLIC PPDValue +{ + PPDValueType m_eType; + //CustomOption stuff for fdo#43049 + //see http://www.cups.org/documentation.php/spec-ppd.html#OPTIONS + //for full specs, only the basics are implemented here + bool m_bCustomOption; + mutable OUString m_aCustomOption; + OUString m_aOption; + OUString m_aValue; +}; + + +/* + * PPDKey - a container for the available options (=values) of a PPD keyword + */ + +class PPDKey +{ + friend class PPDParser; + friend class CPDManager; + + typedef std::unordered_map< OUString, PPDValue > hash_type; + typedef std::vector< PPDValue* > value_type; + + OUString const m_aKey; + hash_type m_aValues; + value_type m_aOrderedValues; + const PPDValue* m_pDefaultValue; + bool m_bQueryValue; + OUString m_aGroup; + +public: + enum class SetupType { ExitServer, Prolog, DocumentSetup, PageSetup, JCLSetup, AnySetup }; +private: + + bool m_bUIOption; + int m_nOrderDependency; + SetupType m_eSetupType; + + void eraseValue( const OUString& rOption ); +public: + PPDKey( const OUString& rKey ); + ~PPDKey(); + + PPDValue* insertValue(const OUString& rOption, PPDValueType eType, bool bCustomOption = false); + int countValues() const + { return m_aValues.size(); } + // neither getValue will return the query option + const PPDValue* getValue( int n ) const; + const PPDValue* getValue( const OUString& rOption ) const; + const PPDValue* getValueCaseInsensitive( const OUString& rOption ) const; + const PPDValue* getDefaultValue() const { return m_pDefaultValue; } + const OUString& getGroup() const { return m_aGroup; } + + const OUString& getKey() const { return m_aKey; } + bool isUIKey() const { return m_bUIOption; } + SetupType getSetupType() const { return m_eSetupType; } + int getOrderDependency() const { return m_nOrderDependency; } +}; + +// define a hash for PPDKey +struct PPDKeyhash +{ + size_t operator()( const PPDKey * pKey) const + { return reinterpret_cast<size_t>(pKey); } +}; + + +/* + * PPDParser - parses a PPD file and contains all available keys from it + */ + +class PPDParser +{ + friend class PPDContext; + friend class CUPSManager; + friend class CPDManager; + friend class PPDCache; + + typedef std::unordered_map< OUString, std::unique_ptr<PPDKey> > hash_type; + typedef std::vector< PPDKey* > value_type; + + void insertKey( std::unique_ptr<PPDKey> pKey ); +public: + struct PPDConstraint + { + const PPDKey* m_pKey1; + const PPDValue* m_pOption1; + const PPDKey* m_pKey2; + const PPDValue* m_pOption2; + + PPDConstraint() : m_pKey1( nullptr ), m_pOption1( nullptr ), m_pKey2( nullptr ), m_pOption2( nullptr ) {} + }; +private: + hash_type m_aKeys; + value_type m_aOrderedKeys; + ::std::vector< PPDConstraint > m_aConstraints; + + // the full path of the PPD file + OUString m_aFile; + // some basic attributes + bool m_bColorDevice; + bool m_bType42Capable; + sal_uLong m_nLanguageLevel; + rtl_TextEncoding m_aFileEncoding; + + + // shortcuts to important keys and their default values + // imageable area + const PPDKey* m_pImageableAreas; + // paper dimensions + const PPDValue* m_pDefaultPaperDimension; + const PPDKey* m_pPaperDimensions; + // paper trays + const PPDValue* m_pDefaultInputSlot; + // resolutions + const PPDValue* m_pDefaultResolution; + + // translations + std::unique_ptr<PPDTranslator> m_pTranslator; + + PPDParser( const OUString& rFile ); + PPDParser(const OUString& rFile, const std::vector<PPDKey*>& keys); + + void parseOrderDependency(const OString& rLine); + void parseOpenUI(const OString& rLine, const OString& rPPDGroup); + void parseConstraint(const OString& rLine); + void parse( std::vector< OString >& rLines ); + + OUString handleTranslation(const OString& i_rString, bool i_bIsGlobalized); + + static void scanPPDDir( const OUString& rDir ); + static void initPPDFiles(PPDCache &rPPDCache); + static OUString getPPDFile( const OUString& rFile ); +public: + ~PPDParser(); + static const PPDParser* getParser( const OUString& rFile ); + + const PPDKey* getKey( int n ) const; + const PPDKey* getKey( const OUString& rKey ) const; + int getKeys() const { return m_aKeys.size(); } + bool hasKey( const PPDKey* ) const; + + const ::std::vector< PPDConstraint >& getConstraints() const { return m_aConstraints; } + + bool isColorDevice() const { return m_bColorDevice; } + bool isType42Capable() const { return m_bType42Capable; } + sal_uLong getLanguageLevel() const { return m_nLanguageLevel; } + + OUString getDefaultPaperDimension() const; + void getDefaultPaperDimension( int& rWidth, int& rHeight ) const + { getPaperDimension( getDefaultPaperDimension(), rWidth, rHeight ); } + bool getPaperDimension( const OUString& rPaperName, + int& rWidth, int& rHeight ) const; + // width and height in pt + // returns false if paper not found + + // match the best paper for width and height + OUString matchPaper( int nWidth, int nHeight ) const; + + bool getMargins( const OUString& rPaperName, + int &rLeft, int& rRight, + int &rUpper, int& rLower ) const; + // values in pt + // returns true if paper found + + // values int pt + + OUString getDefaultInputSlot() const; + + void getDefaultResolution( int& rXRes, int& rYRes ) const; + // values in dpi + static void getResolutionFromString( const OUString&, int&, int& ); + // helper function + + OUString translateKey( const OUString& i_rKey ) const; + OUString translateOption( const OUString& i_rKey, + const OUString& i_rOption ) const; +}; + + +/* + * PPDContext - a class to manage user definable states based on the + * contents of a PPDParser. + */ + +class PPDContext +{ + typedef std::unordered_map< const PPDKey*, const PPDValue*, PPDKeyhash > hash_type; + hash_type m_aCurrentValues; + const PPDParser* m_pParser; + + // returns false: check failed, new value is constrained + // true: check succeeded, new value can be set + bool checkConstraints( const PPDKey*, const PPDValue*, bool bDoReset ); + bool resetValue( const PPDKey*, bool bDefaultable = false ); +public: + PPDContext(); + PPDContext( const PPDContext& rContext ) { operator=( rContext ); } + PPDContext& operator=( const PPDContext& rContext ) = default; + PPDContext& operator=( PPDContext&& rContext ); + + void setParser( const PPDParser* ); + const PPDParser* getParser() const { return m_pParser; } + + const PPDValue* getValue( const PPDKey* ) const; + const PPDValue* setValue( const PPDKey*, const PPDValue*, bool bDontCareForConstraints = false ); + + std::size_t countValuesModified() const { return m_aCurrentValues.size(); } + const PPDKey* getModifiedKey( std::size_t n ) const; + + // public wrapper for the private method + bool checkConstraints( const PPDKey*, const PPDValue* ); + + // for printer setup + char* getStreamableBuffer( sal_uLong& rBytes ) const; + void rebuildFromStreamBuffer(const std::vector<char> &rBuffer); + + // convenience + int getRenderResolution() const; + + // width, height in points, paper will contain the name of the selected + // paper after the call + void getPageSize( OUString& rPaper, int& rWidth, int& rHeight ) const; +}; + +} // namespace + +#endif // INCLUDED_VCL_PPDPARSER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/printerinfomanager.hxx b/vcl/inc/printerinfomanager.hxx index 3ac76a91dde5..020365b8be0a 100644 --- a/vcl/inc/printerinfomanager.hxx +++ b/vcl/inc/printerinfomanager.hxx @@ -26,12 +26,13 @@ #include <unordered_set> #include <vcl/dllapi.h> -#include <vcl/jobdata.hxx> #include <vcl/prntypes.hxx> #include <osl/time.h> #include <cstdio> +#include "jobdata.hxx" + namespace psp { diff --git a/vcl/inc/strhelper.hxx b/vcl/inc/strhelper.hxx new file mode 100644 index 000000000000..be2f5467861f --- /dev/null +++ b/vcl/inc/strhelper.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_VCL_STRHELPER_HXX +#define INCLUDED_VCL_STRHELPER_HXX + +#include <cstring> +#include <rtl/math.hxx> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> + +namespace psp +{ + OUString GetCommandLineToken( int, const OUString& ); + OString GetCommandLineToken(int, const OString&); + // gets one token of a unix command line style string + // doublequote, singlequote and singleleftquote protect their respective + // contents + + int GetCommandLineTokenCount(const OUString&); + // returns number of tokens (zero if empty or whitespace only) + + OUString WhitespaceToSpace( const OUString&, bool bProtect = true ); + OString WhitespaceToSpace(const OString&); + // returns a string with multiple adjacent occurrences of whitespace + // converted to a single space. if bProtect is sal_True (nonzero), then + // doublequote, singlequote and singleleftquote protect their respective + // contents + + + // parses the first double in the string; decimal is '.' only + inline double StringToDouble( const OUString& rStr ) + { + return rtl::math::stringToDouble(rStr, u'.', u'\0'); + } + + inline double StringToDouble(const OString& rStr) + { + return rtl::math::stringToDouble(rStr, '.', static_cast<char>(0)); + } + + // fills a character buffer with the string representation of a double + // the buffer has to be long enough (e.g. 128 bytes) + // returns the string len + inline int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0) + { + OString aStr( rtl::math::doubleToString( f, rtl_math_StringFormat_G, nPrecision, '.', true ) ); + int nLen = aStr.getLength(); + std::strncpy( pBuffer, aStr.getStr(), nLen+1 ); // copy string including terminating zero + return nLen; + } + +} // namespace + +#endif // INCLUDED_VCL_STRHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h index 00e174932851..14917cf72ef5 100644 --- a/vcl/inc/unx/genprn.h +++ b/vcl/inc/unx/genprn.h @@ -20,7 +20,7 @@ #ifndef INCLUDED_VCL_INC_GENERIC_GENPRN_H #define INCLUDED_VCL_INC_GENERIC_GENPRN_H -#include <vcl/jobdata.hxx> +#include <jobdata.hxx> #include <unx/printergfx.hxx> #include <unx/printerjob.hxx> #include <salprn.hxx> diff --git a/vcl/inc/unx/printerjob.hxx b/vcl/inc/unx/printerjob.hxx index 9fe4a3db4945..33f92abc7be8 100644 --- a/vcl/inc/unx/printerjob.hxx +++ b/vcl/inc/unx/printerjob.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX #define INCLUDED_VCL_INC_GENERIC_PRINTERJOB_HXX -#include <vcl/jobdata.hxx> +#include <jobdata.hxx> #include <osl/file.hxx> #include <vector> diff --git a/vcl/inc/vclstatuslistener.hxx b/vcl/inc/vclstatuslistener.hxx new file mode 100644 index 000000000000..2652befcd4cc --- /dev/null +++ b/vcl/inc/vclstatuslistener.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_VCLSTATUSLISTENER_HXX +#define INCLUDED_VCL_VCLSTATUSLISTENER_HXX + +#include <cppuhelper/implbase.hxx> +#include <comphelper/processfactory.hxx> +#include <vcl/vclptr.hxx> + +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> + +template <class T> class VclStatusListener final : public cppu::WeakImplHelper < css::frame::XStatusListener> +{ +public: + VclStatusListener<T>(T* widget, const OUString& aCommand); + +private: + VclPtr<T> mWidget; /** The widget on which actions are performed */ + + /** Dispatcher. Need to keep a reference to it as long as this StatusListener exists. */ + css::uno::Reference<css::frame::XDispatch> mxDispatch; + css::util::URL maCommandURL; + css::uno::Reference<css::frame::XFrame> mxFrame; + +public: + void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) override; + + void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) override; + + const css::uno::Reference<css::frame::XFrame>& getFrame() { return mxFrame; } + + void startListening(); + + void dispose(); +}; + +template<class T> +VclStatusListener<T>::VclStatusListener(T* widget, const OUString& aCommand) { + mWidget = widget; + + css::uno::Reference<css::uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); + css::uno::Reference<css::frame::XDesktop2> xDesktop = css::frame::Desktop::create(xContext); + + css::uno::Reference<css::frame::XFrame> xFrame(xDesktop->getActiveFrame()); + if (!xFrame.is()) + xFrame = xDesktop; + + mxFrame = xFrame; + + maCommandURL.Complete = aCommand; + css::uno::Reference<css::util::XURLTransformer> xParser = css::util::URLTransformer::create(xContext); + xParser->parseStrict(maCommandURL); +} + +template<class T> +void VclStatusListener<T>::startListening() +{ + if (mxDispatch.is()) + mxDispatch->removeStatusListener(this, maCommandURL); + + css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(mxFrame, css::uno::UNO_QUERY); + if (!xDispatchProvider.is()) + return; + + mxDispatch = xDispatchProvider->queryDispatch(maCommandURL, "", 0); + if (mxDispatch.is()) + mxDispatch->addStatusListener(this, maCommandURL); +} + +template<class T> +void VclStatusListener<T>::statusChanged(const css::frame::FeatureStateEvent& rEvent) +{ + mWidget->statusChanged(rEvent); +} + +template<class T> +void VclStatusListener<T>::disposing(const css::lang::EventObject& /*Source*/) +{ + mxDispatch.clear(); +} + +template<class T> +void VclStatusListener<T>::dispose() +{ + if (mxDispatch.is()) { + mxDispatch->removeStatusListener(this, maCommandURL); + mxDispatch.clear(); + } + mxFrame.clear(); + mWidget.clear(); +} + + +#endif // INCLUDED_VCL_VCLSTATUSLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |